package com.aop.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class TimeHandler implements InvocationHandler {

    private Object target;  //目标方法
    public TimeHandler(Object object){
        this.target = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("吃饭前要洗手");
        //调用真正的方法
        Object invoke = method.invoke(target, args);
        System.out.println("吃饭后要洗手");
        return invoke;
    }


}
